﻿package cz.dadul.adventure.controller
{
	/**
	 * ...
	 * @author Dadul
	 */
	import flash.display.*;
	import flash.events.*;
	import cz.dadul.adventure.model.*;
	import cz.dadul.adventure.view.*;
	import cz.dadul.adventure.model.events.*;
	 
	 public class StorageController extends EventDispatcher
	{
		// Constants
		// Singleton instance
		private static var instance:StorageController;
		
		// Variables
		private var _storage:Storage;


		public function StorageController(p_key:SingletonBlocker):void{
			// this shouldn't be necessary unless they fake out the compiler:
			 if (p_key == null) {
				throw new Error("Error: Instantiation failed: Use StorageController.getInstance() instead of new.");
			  }
			  init();
		}

				
		
		public function addItem(item:PickableItem):void {
			this._storage.addItem(item);
		}
		
		public function dock(item:PickableItem):void {
			this._storage.dock(item);
		}
		
		/**
		 * PRIVATE
		 */
		private function init():void { }

		
		
		/**
		 * STATIC
		 */
		public static function getInstance():StorageController {
         if (instance == null) {
            instance = new StorageController(new SingletonBlocker());
          }
         return instance;
		}
		
		/*
		 * 	SETTER / GETTER
		 */ 
		public function set storage(st:Storage):void {
			this._storage = st;
		}
		public function get storage():Storage {
			return this._storage;
		}
		
		
	}
	
}

internal class SingletonBlocker {}